<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>字母大小写转换</title>
</head>

<body>

</body>

</html>
<script>
    function upper_lower(str) {
        let string = ''
        for (let i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) >= '97' && str.charCodeAt(i) <= '122') {
                string += str[i].toUpperCase()
            } else if (str.charCodeAt(i) >= '65' && str.charCodeAt(i) <= '90') {
                string += str[i].toLowerCase()
            }
        }
        return string
    }
    let str = 'HelloWorld'
    console.log(upper_lower(str));
</script>